package com.ruike.alisurface.https;

import com.ruike.alisurface.utils.GsonUtils;
import com.ruike.alisurface.utils.ShareKey;
import com.voodoo.lib_http.ApiListener;
import com.voodoo.lib_http.ApiTools;
import com.voodoo.lib_utils.SharedUtils;

import java.util.HashMap;
import java.util.Map;

public class SettingHttp {

    private static String url = "https://rk.shouhuojiyun.com/rk_medicine_api/android_manage/";//总地址

    public static String login = "login";//管理端登录
    public static String get_mch_slot_setting_list = "get_mch_slot_setting_list";//货道设置列表
    public static String mch_one_key_replenishment = "mch_one_key_replenishment_for_android";
    public static String get_slot_position_detail = "get_slot_position_detail";//获取货道位置详细信息
    public static String get_slot_product_list = "get_slot_product_list";//货道商品下拉列表
    public static String edit_slot_position="edit_slot_position";//保存货道位置信息
    public static String edit_slot="edit_slot";//保存货道信息

    /**
     * 管理端登录
     *
     * @param mApiListener
     */
    public static void post_Login(String username, String ped, ApiListener mApiListener) {
        Map map = new HashMap();
        map.put("username", username);
        map.put("pwd", ped);
        String json = GsonUtils.toJson(map);
        ApiTools.getInstance().post(url + login, json, mApiListener);
    }

    /**
     * 管理端登录
     *
     * @param mApiListener
     */
    public static void mch_one_key_replenishment(ApiListener mApiListener) {
        Map map = new HashMap<>();
        map.put("mchid", SharedUtils.getInstance().getString(ShareKey.MCH_ID));
        Map header = new HashMap<>();
        String tiken = SharedUtils.getInstance().getString("token");

        header.put("token", tiken);
        ApiTools.getInstance().get(url + mch_one_key_replenishment, map, header, mApiListener);
    }


    /**
     * 货道设置列表
     *
     * @param mApiListener
     */
    public static void get_mch_slot_setting_list(int page, int pagesize, ApiListener mApiListener) {
        Map map = new HashMap();
        map.put("mch_id", SharedUtils.getInstance().getString(ShareKey.MCH_ID));
        map.put("page", page);
        map.put("pagesize", pagesize);
        String json = GsonUtils.toJson(map);
        HashMap header = new HashMap<>();
        String tiken = SharedUtils.getInstance().getString("token");

        header.put("token", tiken);
        ApiTools.getInstance().post(url + get_mch_slot_setting_list, json, header, mApiListener);
    }


    /**
     * 获取货道详细信息 1=货道详情，2=货道位置详情
     *
     * @param mApiListener
     */
    public static void get_slot_position_detail(String slot_id, int type, ApiListener mApiListener) {
        Map map = new HashMap();
        map.put("slot_id", slot_id);
        map.put("type", type);

        HashMap header = new HashMap<>();
        String tiken = SharedUtils.getInstance().getString("token");
        header.put("token", tiken);
        ApiTools.getInstance().get(url + get_slot_position_detail, map, header, mApiListener);
    }


    /**
     *货道商品下拉列表
     *
     * @param mApiListener
     */
    public static void get_slot_product_list(  ApiListener mApiListener) {
        Map map = new HashMap();
        HashMap header = new HashMap<>();
        String tiken = SharedUtils.getInstance().getString("token");
        header.put("token", tiken);
        ApiTools.getInstance().get(url + get_slot_product_list, map, header, mApiListener);
    }
    /**
     *保存货道位置信息
     *
     * @param mApiListener
     */
    public static void edit_slot_position( String json,  ApiListener mApiListener) {

        HashMap header = new HashMap<>();
        String token = SharedUtils.getInstance().getString("token");
        header.put("token", token);
        ApiTools.getInstance().post(url + edit_slot_position, json, header, mApiListener);
    }

    /**
     *保存货道信息
     *
     * @param  mApiListener
     */
    public static void edit_slot( String json, ApiListener mApiListener) {
        HashMap header = new HashMap<>();
        String tiken = SharedUtils.getInstance().getString("token");
        header.put("token", tiken);
        ApiTools.getInstance().post(url + edit_slot, json, header, mApiListener);
    }
}
